<template>
	<div class="table-box">
	<div class="menu-edit">
		<el-page-header @back="goBack" :content="(id?'编辑':'新增')+'权限组'"></el-page-header>
		<el-form ref="form" :model="model" label-width="200px">
			<el-form-item label="权限组名称">
				<el-input v-model="model.name"></el-input>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="onSubmit">立即{{id?"保存":"创建"}}</el-button>
				<el-button @click="goBack">取消</el-button>
			</el-form-item>
		</el-form>
	</div>
	</div>
</template>

<script>
	
	export default {
		props: {
			id: String
		},
		data() {
			return {
				groups: [],
				model: {
					id:0,
					name: ""
				}
			}
		},
		async created() {
			if(this.id){
				let model = await this.$http.get('group/detail?id='+this.id)
				this.model = model
			}
		},
		methods: {
			async onSubmit() {
				let url = this.id?"group/edit":"group/add"
				await this.$http.post(url,this.model)
				this.$message.success('操作成功')
				this.$router.go(-1)
			},
			goBack(){
				this.$router.go(-1)
			}
		},
	};
</script>

<style scoped>
	
</style>
